package com.gzz.orchid.context.application.inventory.convert;

import com.gzz.orchid.context.application.inventory.command.ReceivedSaveCmd;
import com.gzz.orchid.context.application.inventory.pojo.ReceivedDto;
import com.gzz.orchid.context.application.inventory.pojo.ReceivedVo;
import com.gzz.orchid.context.infrastructure.definition.Status;
import com.gzz.orchid.context.infrastructure.persistence.entity.inv.InvReceivedPo;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

/**
 * @author higmd
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, imports = {Status.class})
public interface ReceivedConverter {
    ReceivedConverter INSTANCE = Mappers.getMapper(ReceivedConverter.class);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))")
    })
    ReceivedVo mapVo(InvReceivedPo po);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))")
    })
    ReceivedDto mapDto(InvReceivedPo po);

    //
    void updatePo(@MappingTarget InvReceivedPo po, ReceivedSaveCmd cmd);
}
